package com.kedacom.demo.modularity.email;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "email")
public class Email {

	protected static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	private Long id;
	private String subject; // 主题
	private String body; // 正文
	private Date createdAt; // 创建时间
	private String from; // 发送方
	private String to; // 接收方

	public Email() {
	}

	public Email(Long id, String subject, String body, String from, String to) {
		this.id = id;
		this.subject = subject;
		this.body = body;
		this.from = from;
		this.to = to;
		this.createdAt = Calendar.getInstance().getTime();
	}

	public String toString() {
		return String.format("{id=%s,subject=%s,body=%s,from=%s,to=%s,createdAt=%s}", id, subject, body, from, to,
				formatter.format(createdAt));
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public Date getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}

	public String getFrom() {
		return from;
	}

	public void setFrom(String from) {
		this.from = from;
	}

	public String getTo() {
		return to;
	}

	public void setTo(String to) {
		this.to = to;
	}

}
